<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The EvIdle class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="evfork.createstopped.html">« EvFork::createStopped</a></li>
      <li style="float: right;"><a href="evidle.construct.html">EvIdle::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.ev.html">Ev</a></li>
    <li>The EvIdle class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.evidle" class="reference">
 <h1 class="title">The EvIdle class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL ev &gt;= 0.2.0)</p>

  <div class="section" id="evidle.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <span class="classname"><strong class="classname">EvIdle</strong></span>
    watchers trigger events when no other events of the same or higher
    priority are pending (
    <span class="classname"><a href="class.evprepare.html" class="classname">EvPrepare</a></span>
    ,
    <span class="classname"><a href="class.evcheck.html" class="classname">EvCheck</a></span>
    and other
    <span class="classname"><strong class="classname">EvIdle</strong></span>
    watchers do not count as receiving
    <em class="emphasis">events</em>
    ).
   </p>
   <p class="para">
    Thus, as long as the process is busy handling sockets or timeouts(or even
    signals) of the same or higher priority it will not be triggered. But when
    the process is in idle(or only lower-priority watchers are pending), the
    <span class="classname"><strong class="classname">EvIdle</strong></span>
    watchers are being called once per event loop iteration - until stopped,
    that is, or the process receives more events and becomes busy again with
    higher priority stuff.
   </p>
   <p class="para">
    Apart from keeping the process non-blocking(which is a useful on its own
    sometimes),
    <span class="classname"><strong class="classname">EvIdle</strong></span>
    watchers are a good place to do
    <em class="emphasis">&quot;pseudo-background processing&quot;</em>
    , or delay processing stuff to after the event loop has handled all
    outstanding events.
   </p>
   <p class="para">
    The most noticeable effect is that as long as any
    <em class="emphasis">idle</em>
    watchers are active, the process will
    <em class="emphasis">not</em>
    block when waiting for new events.
   </p>
  </div>

  <div class="section" id="evidle.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">EvIdle</strong>
     </span>
     <span class="ooclass">
      <span class="modifier">extends</span>
       <a href="class.evwatcher.html" class="classname">EvWatcher</a>
     </span>
     {</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-active">$<var class="varname">is_active</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.data">$<var class="varname">data</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-pending">$<var class="varname">is_pending</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.priority">$<var class="varname">priority</var></a></var>;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><a href="evidle.construct.html" class="methodname">__construct</a></span>(<span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>, <span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
   <span class="initializer"> = ?</span></span>, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
   <span class="initializer"> = ?</span></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">final</span>
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="methodname"><a href="evidle.createstopped.html" class="methodname">createStopped</a></span>(<span class="methodparam">
    <span class="type">string</span>
     <code class="parameter">$callback</code>
   </span>, <span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
   <span class="initializer"> = ?</span></span>, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
   <span class="initializer"> = ?</span></span>): <span class="type">object</span></div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.clear.html" class="methodname">EvWatcher::clear</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.feed.html" class="methodname">EvWatcher::feed</a></span>(<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.getloop.html" class="methodname">EvWatcher::getLoop</a></span>(): <span class="type"><a href="class.evloop.html" class="type EvLoop">EvLoop</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.invoke.html" class="methodname">EvWatcher::invoke</a></span>(<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.keepalive.html" class="methodname">EvWatcher::keepalive</a></span>(<span class="methodparam">
    <span class="type">bool</span>
     <code class="parameter">$value</code>
   <span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.setcallback.html" class="methodname">EvWatcher::setCallback</a></span>(<span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.start.html" class="methodname">EvWatcher::start</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.stop.html" class="methodname">EvWatcher::stop</a></span>(): <span class="type"><span class="type void">void</span></span></div>

   }</div>

  </div>

 </div>

 











<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="evidle.construct.html">EvIdle::__construct</a> — Constructs the EvIdle watcher object</li><li><a href="evidle.createstopped.html">EvIdle::createStopped</a> — Creates instance of a stopped EvIdle watcher object</li></ul>
</div>
</div></div></body></html>